﻿using System;
using System.IO;
using System.Text;
using UnityEngine;
using XUpdater;

namespace XUtliPoolLib
{
	// Token: 0x0200004F RID: 79
	public class AssetBundlePathResolver
	{
		// Token: 0x06000292 RID: 658 RVA: 0x00014687 File Offset: 0x00012887
		public AssetBundlePathResolver()
		{
			AssetBundlePathResolver.instance = this;
		}

		// Token: 0x17000065 RID: 101
		// (get) Token: 0x06000293 RID: 659 RVA: 0x000146B0 File Offset: 0x000128B0
		public virtual string BundleSaveDirName
		{
			get
			{
				return "AssetBundles";
			}
		}

		// Token: 0x17000066 RID: 102
		// (get) Token: 0x06000294 RID: 660 RVA: 0x000146C8 File Offset: 0x000128C8
		public string AndroidBundleSavePath
		{
			get
			{
				return "Assets/StreamingAssets/update/Android/" + this.BundleSaveDirName;
			}
		}

		// Token: 0x17000067 RID: 103
		// (get) Token: 0x06000295 RID: 661 RVA: 0x000146EC File Offset: 0x000128EC
		public string iOSBundleSavePath
		{
			get
			{
				return "Assets/StreamingAssets/update/iOS/" + this.BundleSaveDirName;
			}
		}

		// Token: 0x17000068 RID: 104
		// (get) Token: 0x06000296 RID: 662 RVA: 0x00014710 File Offset: 0x00012910
		public string DefaultBundleSavePath
		{
			get
			{
				return "Assets/StreamingAssets/update/" + this.BundleSaveDirName;
			}
		}

		// Token: 0x17000069 RID: 105
		// (get) Token: 0x06000297 RID: 663 RVA: 0x00014734 File Offset: 0x00012934
		public virtual string AndroidHashCacheSaveFile
		{
			get
			{
				return "Assets/AssetBundles/Android/cache.txt";
			}
		}

		// Token: 0x1700006A RID: 106
		// (get) Token: 0x06000298 RID: 664 RVA: 0x0001474C File Offset: 0x0001294C
		public virtual string iOSHashCacheSaveFile
		{
			get
			{
				return "Assets/AssetBundles/iOS/cache.txt";
			}
		}

		// Token: 0x1700006B RID: 107
		// (get) Token: 0x06000299 RID: 665 RVA: 0x00014764 File Offset: 0x00012964
		public virtual string DefaultHashCacheSaveFile
		{
			get
			{
				return "Assets/AssetBundles/cache.txt";
			}
		}

		// Token: 0x0600029A RID: 666 RVA: 0x0001477C File Offset: 0x0001297C
		public virtual string GetEditorModePath(string abName)
		{
			abName = abName.Replace(".", "/");
			int num = abName.LastIndexOf("/");
			bool flag = num == -1;
			string result;
			if (flag)
			{
				result = abName;
			}
			else
			{
				string text = string.Format("{0}.{1}", abName.Substring(0, num), abName.Substring(num + 1));
				result = text;
			}
			return result;
		}

		// Token: 0x0600029B RID: 667 RVA: 0x000147D8 File Offset: 0x000129D8
		public virtual string GetBundleSourceFile(string path, bool forWWW = true)
		{
			if (forWWW)
			{
				bool flag = this.cachePathWWW == null;
				if (flag)
				{
					RuntimePlatform platform = Application.platform;
					if (platform != RuntimePlatform.IPhonePlayer)
					{
						if (platform != RuntimePlatform.Android)
						{
							this.cachePathWWW = string.Format("file://{0}/StreamingAssets/update/{1}/", Application.dataPath, this.BundleSaveDirName);
						}
						else
						{
							this.cachePathWWW = string.Format("jar:file://{0}!/assets/update/Android/{1}/", Application.dataPath, this.BundleSaveDirName);
						}
					}
					else
					{
						this.cachePathWWW = string.Format("file://{0}/Raw/update/iOS/{1}/", Application.dataPath, this.BundleSaveDirName);
					}
				}
				this.pathSB.Length = 0;
				this.pathSB.Append(this.cachePathWWW);
			}
			else
			{
				bool flag2 = this.cachePath == null;
				if (flag2)
				{
					RuntimePlatform platform2 = Application.platform;
					if (platform2 != RuntimePlatform.IPhonePlayer)
					{
						if (platform2 != RuntimePlatform.Android)
						{
							this.cachePath = string.Format("{0}/StreamingAssets/update/{1}/", Application.dataPath, this.BundleSaveDirName);
						}
						else
						{
							this.cachePath = string.Format("{0}!assets/update/Android/{1}/", Application.dataPath, this.BundleSaveDirName);
						}
					}
					else
					{
						this.cachePath = string.Format("{0}/Raw/update/iOS/{1}/", Application.dataPath, this.BundleSaveDirName);
					}
				}
				this.pathSB.Length = 0;
				this.pathSB.Append(this.cachePath);
			}
			this.pathSB.Append(path);
			return this.pathSB.ToString();
		}

		// Token: 0x1700006C RID: 108
		// (get) Token: 0x0600029C RID: 668 RVA: 0x00014948 File Offset: 0x00012B48
		public virtual string DependFileName
		{
			get
			{
				return "dep.all";
			}
		}

		// Token: 0x1700006D RID: 109
		// (get) Token: 0x0600029D RID: 669 RVA: 0x00014960 File Offset: 0x00012B60
		public virtual string BundleCacheDir
		{
			get
			{
				bool flag = this.cacheDir == null;
				if (flag)
				{
					RuntimePlatform platform = Application.platform;
					string path;
					if (platform != RuntimePlatform.IPhonePlayer)
					{
						if (platform != RuntimePlatform.Android)
						{
							XPlatformType xplatformType = XSingleton<XUpdater.XUpdater>.singleton.XPlatform.Platfrom();
							XPlatformType xplatformType2 = xplatformType;
							if (xplatformType2 != XPlatformType.IOS)
							{
								if (xplatformType2 != XPlatformType.Android)
								{
									path = string.Format("{0}/update/AssetBundles", Application.streamingAssetsPath);
								}
								else
								{
									path = string.Format("{0}/update/Android/AssetBundles", Application.streamingAssetsPath);
								}
							}
							else
							{
								path = string.Format("{0}/update/iOS/AssetBundles", Application.streamingAssetsPath);
							}
						}
						else
						{
							path = string.Format("{0}/update/AssetBundles", Application.persistentDataPath);
						}
					}
					else
					{
						path = string.Format("{0}/update/AssetBundles", Application.persistentDataPath);
					}
					this.cacheDir = new DirectoryInfo(path);
					bool flag2 = !this.cacheDir.Exists;
					if (flag2)
					{
						this.cacheDir.Create();
					}
				}
				return this.cacheDir.FullName;
			}
		}

		// Token: 0x04000251 RID: 593
		public static AssetBundlePathResolver instance;

		// Token: 0x04000252 RID: 594
		private string cachePath = null;

		// Token: 0x04000253 RID: 595
		private string cachePathWWW = null;

		// Token: 0x04000254 RID: 596
		private StringBuilder pathSB = new StringBuilder();

		// Token: 0x04000255 RID: 597
		private DirectoryInfo cacheDir;
	}
}
